/*
 * @Date: 2023-07-14 09:12:34
 * @LastEditors: lyx
 * @LastEditTime: 2023-07-14 11:17:46
 * @FilePath: \sup-mimi-program-server\src\weather\weather.service.ts
 * @Description:
 */
import { Injectable } from '@nestjs/common';
import axios from 'axios';
import { CreateWeatherDto } from './dto/create-weather.dto';
import { GetWeatherDto } from './dto/get-weather.dto';
import { UpdateWeatherDto } from './dto/update-weather.dto';

@Injectable()
export class WeatherService {
  async getWeather(getWeatherDto: GetWeatherDto) {
    const queryWeatherDto = {
      key: '6aef6c4c43f3ea15216d104532861852', //　TODO：高德地图　天气　API　需要提取到外部
      ...getWeatherDto,
    };

    const res = await axios.get(
      `https://restapi.amap.com/v3/weather/weatherInfo`,
      {
        params: {
          ...queryWeatherDto,
        },
      },
    );
    console.log('res', res);
    return res?.data ?? {};
  }
}
